#ifndef _LIBCCD_COLLISION_H_
#define _LIBCCD_COLLISION_H_
#include "btBulletCollisionCommon.h"
#include "ccd/ccd.h"
#include "ccd/quat.h"

struct _ccd_obj_t {
    ccd_vec3_t pos;
    ccd_quat_t rot, rot_inv;
};
typedef struct _ccd_obj_t ccd_obj_t;

struct _ccd_cyl_t {
    ccd_obj_t o;
    ccd_real_t radius, height;
};
typedef struct _ccd_cyl_t ccd_cyl_t;

struct _ccd_box_t {
    ccd_obj_t o;
    ccd_real_t dim[3];
};
typedef struct _ccd_box_t ccd_box_t;

//int dCollideCylinderCylinder(dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip);
typedef struct ContactGeom {
	btVector3 pos;          ///< contact position
	btVector3 normal;       ///< normal vector
	btScalar depth;         ///< penetration depth
	const btCollisionObject* g1;  ///< the colliding geoms
	const btCollisionObject* g2;
	int side1,side2;        ///< (to be documented)
} dContactGeom;

int ccdCollide(const btCollisionObject* o1, const btCollisionObject* o2, int flags,
                      ContactGeom *contact, int skip,
                      void *obj1, ccd_support_fn supp1, ccd_center_fn cen1,
                      void *obj2, ccd_support_fn supp2, ccd_center_fn cen2);

void ccdSupportBox(const void *obj, const ccd_vec3_t *_dir, ccd_vec3_t *v);
void ccdSupportCyl(const void *obj, const ccd_vec3_t *_dir, ccd_vec3_t *v);

void ccdCenter(const void *obj, ccd_vec3_t *c);

void ccdGeomToBox(const btCollisionObject* collisionObject, ccd_box_t *box);
void ccdGeomToCyl(const btCollisionObject* collisionObject, ccd_cyl_t *cyl);

#endif _LIBCCD_COLLISION_H_